<template>
	<view class="" style="overflow: hidden;">
		<view class="cf-container">
			<view class="tab">
				<view @click="changeState(2)"><text :class="state == 2 ? 'ns-text-color active ns-border-color-bottom' : ''">未使用</text></view>
				<view @click="changeState(1)"><text :class="state == 1 ? 'ns-text-color active ns-border-color-bottom' : ''">已使用</text></view>
				<view @click="changeState(3)"><text :class="state == 3 ? 'ns-text-color active ns-border-color-bottom' : ''">已过期</text></view>
			</view>
		</view>
			<block v-if="listData.length>0">
				<view class="coupon-list" >
					<view class="coupon-item u-flex u-flex-between" :class="{'out':state==1||state==3}"  v-for="(item,idx) in listData" :key="idx">
						<view class="l">
							<view class="t1">{{item.tickettype}}</view>
							<view class="t2">{{item.ticketname}}</view>
							<view class="t3">有效期{{item.startdate}} -{{item.enddate}}</view>
						</view>
						<view class="r u-flex u-flex-center u-flex-y-center">
							<view class="m ">
								<text>¥</text>{{item.je}}
							</view>
						</view>
					</view>
				<!-- 	<view class="coupon-item u-flex u-flex-between out">
						<view class="l">
							<view class="t1">手机消费赠送</view>
							<view class="t2">APP5元面包卷满20可用</view>
							<view class="t3">有效期2020.3.5 -2020.9.20</view>
						</view>
						<view class="r u-flex u-flex-center u-flex-y-center">
							<view class="m ">
								<text>¥</text>5
							</view>
						</view>
					</view> -->
				</view>
				<u-loadmore
						marginBottom="50"
				        :status="status" 
				        :loading-text="loadingText" 
				        :loadmore-text="loadmoreText" 
				        :nomore-text="nomoreText" 
				/>
			</block>
			<block v-else>
				<u-empty marginTop="100" :text="emptyTips" mode="coupon"></u-empty>
			</block>
		
		<!-- <loading-cover ref="loadingCover"></loading-cover> -->
		
	</view>
</template>

<script>

	export default{
		components:{
			
		},
		data() {
			return {
				state: 2,
				imgUrl:this.imgUrl,
				pageindex:1,
				listData:[],
				emptyTips:"还没有优惠券哦",
				status: 'loadmore',
				loadingText: '努力加载中',
				loadmoreText: '轻轻上拉',
				nomoreText: '没有了哦'
			}
		},
		  computed: {
		      
		    },
		onLoad() {
			this.getCounponList();
		},
		methods: {
			changeState(state) {
				this.pageindex = 1;
				this.state = state;
				this.getCounponList()
			},
			getCounponList(){
				this.status = "loading";
				if(this.pageindex==1){
					this.listData = [];
				}
				this.$http.GetTicticket({
					pagesize:20,
					pageindex:this.pageindex,
					state:this.state,
					cardno:uni.getStorageSync('userInfo').cardNo
				})
				// this.$http.GetProductList({
				// 	tagid:2,
				// 	pagesize:10,
				// 	pageindex:this.pageindex,
				// 	storeId:5
				// })
				.then(res => {
					if(res.code==0){
					this.status = "loadmore";
					if(res.content.tickets.length>0){
						this.listData = this.listData.concat(res.content.tickets);
						if(res.content.tickets.length<10){
							this.status = "nomore"
						}
					}else{
						this.status = "nomore"
					}
					}
					
				})
			}
		},
		onReachBottom() {
			this.pageindex ++;
			this.getCounponList()
		}
	}
</script>

<style lang="scss" scoped>
	.cf-container {
		background: #fff;
		overflow: hidden;
	}
	.active {
		border-bottom:4rpx solid #BEB49D;
		color: #BEB49D;
	}
	.tab {
		display: flex;
		justify-content: space-between;
	
		> view {
			text-align: center;
			width: 33%;
	
			text {
				display: inline-block;
				line-height: 58rpx;
			}
		}
	}
	
	.coupon-item{
		padding: 20rpx;color: #fff;margin: 20rpx auto 0;
		width: 666rpx;height: 186rpx;
		background: url(https://hongpei.oss-cn-hangzhou.aliyuncs.com/img/yhq.png) no-repeat;
		background-size: 100% 100%;
		.t1{
			font-size: 32rpx;
		}
		.t2{
			font-size: 24rpx;margin-left: 24rpx;
		}
		.t3{font-size: 20rpx;margin-top: 26rpx;}
		.r{
			width: 200rpx;
			.m{
				color:#000 ;
				font-size: 80rpx;
				text{
					font-size: 20rpx;
					
				}
			}
		}
		&.out{
			filter: grayscale(1);
			opacity: .6;
			background-image:url(https://hongpei.oss-cn-hangzhou.aliyuncs.com/img/yhq_l.png)  ;
		}
	}
</style>